<include file="Public:top" />
<!--头部 end-->
<script type="text/javascript" src="__PUBLIC__/js/ajaxfileupload.js"></script>
 <include file="Public:menu" /> 
 <!--菜单 end-->
<form  id='crewForm' >

            <div class="form-group">
                    <div class="label"><label for="title">科室分类</label></div>
                    <div class="field">
                        <select id="ty_id"  name="ty_id">
                            <if condition="$f_pid['ty_id'] == null">
                                <option value="1">顶级</option>
                                <else />
                                <option value="{$f_pid['ty_id']}">{$f_pid['title']}</option>
                            </if>
                            <foreach name='type' item='v'>
                                <option value="{$v.ty_id}">{$v.title}</option>
                            </foreach>
                       </select>
                    </div>
            </div>

			<div class="form-group">
                    <div class="label"><label for="title">医生姓名</label></div>
                    <div class="field">
                        <input type="text" class="input"  name="td_name" size="20" value="{$result.td_name}" placeholder="请填写菜品名称" data-validate="required:请填写菜品，建议在6字以内。" style="width:40%;" />
                    </div>
            </div>
            <div class="form-group">
                    <div class="label"><label for="title">排序</label></div>
                    <div class="field">
                        <input type="number" class="input"  name="sort" size="20" value="{$result.sort}" placeholder="请填写数字" style="width:20%;" />
                    </div>
            </div>
    <div class="form-group">
        <div class="label"><label for="title">是否显示</label></div>
        <div class="field">
            <input type="number" class="input"  name="is_show" size="20" value="{$result.is_show}" placeholder="请填写数字" style="width:20%;" />
            <p>1为显示；0为隐藏；</p>
        </div>
    </div>
                <div class="form-group">
                    <div class="label"><label for="logo">头像图：</label></div>
                    <div class="field">
                        <a class="button input-file" href="javascript:void(0);">+ 浏览文件
                            <input size="100" type="file" id="fileToUploade" name="upload"  data-validate="required:请选择上传头像图片,regexp#.+.(jpg|jpeg|png|gif)$:只能上传jpg|gif|png格式文件" /></a>
                    </div>

                </div>
                <div class="form-group">
                    <div class="label"><label for="logo">医生头像预览图：</label></div>

                    <if condition="$result['base_img']==null">
                        <img id="preview" src="__PUBLIC__/console/images/metx.png" alt="" width="160px" height="180px" />
                        <else/>
                        <img src="{$result.base_img}" alt="" id="preview" width="160px" height="180px">
                    </if>
                    <input type="hidden"  name="base_img" value="{$result[base_img]}">
                </div>


              <div class="form-group">
                    <div class="label"><label for="readme">职称</label></div>
                    <div class="field">
                        <textarea class="input" name="td_text" rows="5" cols="50" placeholder="请填写简介说明" data-validate="required:请填写简介说明">{$result.td_text}</textarea>
                    </div>
                </div>
             <div class="form-group">
                                <script src="__PUBLIC__/ue/ueditor.config.js"></script>
                                <script src="__PUBLIC__/ue/ueditor.all.min.js"></script>
                            <div class="label"><label for="readme">医生简介</label></div>
                            <div class="field">
                                <textarea  name="td_content" id="editor" rows="5" cols="50" placeholder="请填写维护说明" data-validate="required:请填写维护说明">{$result.td_content}</textarea>
                                 <script>
                                         var ue = UE.getEditor("editor",{
                                            toolbars: [
                                                ['fullscreen', 'source',  'redo','bold','italic','|','customstyle','backcolor','removeformat', 'selectall','cleardoc', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','fontfamily','fontsize','paragraph','forecolor',]
                                            ],
                                            autoHeightEnabled: true,
                                            autoFloatEnabled: true,
                                            initialFrameHeight:420
                                        });
                                 </script>
                              </div>
                            </div>
                            <input type="hidden" name="td_id" value="{$result.td_id}">
       <div class="form-button" align="center"><button class="button bg-main" enctype="multipart/form-data" id="sure" type="submit">提交</button></div>

</form>


  <include file="Public:box" /> 
 <!--底部 end-->
 <script>
    //异步表单提交
        $('#sure').click(function(){

            $.post('/Console/product/doUpdate',$('form').serialize(),function(data){

                if ( data.status )
                {
                    layer.alert(data.info, 1);

                    //刷新当前页
                    location.href = "/Console/product";
                }
                else
                {

                    layer.alert(data.info);

                }

            },'json');

            return false;

        })

</script>

<script>
    //异步图片上传
    $('body').on('change','#fileToUploade',function(){

        $.ajaxFileUpload
        (
            {
                url:'/console/product/uploadImg1',
                secureuri:false,
                fileElementId:'fileToUploade',
                dataType: 'json',
                success: function (data)
                {
                    //成功
                    if ( data.status )
                    {
                        $('#preview').attr('src', data.path);
                        $("[name='base_img']").val(data.path);
                    }
                    //失败
                    else
                    {
                        layer.alert(data.info);
                    }

                }
            }
        )


    })

</script>





<script type="text/javascript">
    $("#Upload_img").on("change",headPortraitListener);
    /*定义全局变量存贮图片信息*/
    var base64head="";
    /*头像上传监听*/
    function headPortraitListener(e) {
        var img = document.getElementById('url_img');
        if(window.FileReader) {
            var file  = e.target.files[0];
            var reader = new FileReader();
            if (file && file.type.match('image.*')) {
                reader.readAsDataURL(file);
            } else {
                img.css('display', 'none');
                img.attr('src', '');
            }
            reader.onloadend = function (e) {
                img.setAttribute('src', reader.result)
                $("#input_img").val(reader.result);

                base64head = reader.result;
            }
        }
    }
</script>